
<script>
  import $ from 'dfish-widget'
  import Widget from '../Widget.vue'
  import text from '../widget.text.js'

  export default {
    mixins: [Widget],
    data() {
      return {
        name: 'Confirm',
        remark: '确认提示框',
        extends: [text],
        attrs: [{
          name: 'escape',
          remark: '设置为false，文本参数text将以html格式显示。',
          type: 'Boolean',
          default: 'true'
        },{
          name: 'yes',
          remark: '点击确定时触发',
          type: 'Function',
        }, {
          name: 'icon',
          remark: '图标',
          type: 'String',
        }, {
          name: 'no',
          remark: '点击取消或关闭时触发',
          type: 'Function',
        },{
          name: 'cover',
          remark: '是否显示一个全屏的半透明蒙版',
          type: 'Boolean',
        },],
        examples: [{
          remark: '点击"测试"按钮，弹出确认框',
          type: 'html',
					view: true,
          code: `
            <template>
              <w-button @click="click" text="测试"></w-button>
            </template>
            <${'script'}>
              import $ from 'dfish-widget'
              export default {
                methods: {
                  click(e) {
                    $(e).pop('w-confirm', {
                      text: '确定吗？',
                      cover: true,
                      yes: () => console.log('yes!'),
                      no: () => console.log('no!'),
                    })
                  }
                }
              }
            </${'script'}>
          `,
					comp: {
						methods: {
							click(e) {
							  $(e).pop('w-confirm', {
							    text: '确定吗？',
									cover: true,
							    yes: () => console.log('yes!'),
							    no: () => console.log('no!'),
							  })
							}
						}
					}
        }, {
          remark: 'await用法',
          type: 'html',
					view: true,
          code: `
            <template>
              <w-button @click="click" text="测试"></w-button>
            </template>
            <${'script'}>
              import $ from 'dfish-widget'
              export default {
                methods: {
                  async click(e) {
                    await $(e).pop('w-confirm', {text: '确定吗？', cover: true})
                    console.log('yes')
                  }
                }
              }	
            </${'script'}>
          `,
					comp: {
						methods: {
							async click(e) {
							  await $(e).pop('w-confirm', {text: '确定吗？', cover: true})
							  console.log('yes')
							}
						}
					}
        }]
      }
    }
  }
</script>
